package com.qczl.pme.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.qczl.util.MD5;

/**
 * 人员信息表
 * 
 * @author SongR
 * 
 */
@Entity
@Table(name="pme_basis_person")
public class PMEPerson implements Serializable {
	private static final long serialVersionUID = -1308829443820041555L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "person_id")
	private Long id;// 编号
	@Column(name = "person_name")
	private String name;// 姓名
	@Column(name = "person_birthday")
	private String birthday;// 出生日期
	@Column(name = "person_sex")
	private Integer sex;// 性别
	@Column(name = "person_idcard")
	private String idCard;// 身份证号
	@Column(name = "person_phone")
	private String phone;// 电话号
	@Column(name = "person_politics")
	private String politics;// 政治面貌
	@Column(name = "person_nation")
	private String nation;// 民族
	@Column(name = "person_joinpartytime")
	private String joinPartyTime;// 入党日期
	@Column(name = "person_address")
	private String address;// 家庭住址
	@Column(name = "person_education")
	private String education;// 文化程度
	@Column(name = "person_joinworktime")
	private String joinworktime;// 参加工作日期
	@Column(name = "person_identity")
	private String identity;// 身份
	@Column(name = "person_password")
	private String password;// 密码
	@Column(name = "person_creattime")
	private Date creattime;// 创建时间
	@Column(name = "person_status")
	private Integer status;// 状态  0表示可用 1表示不可用 -1表示已删除
	@Column(name = "person_sort")
	private Long sort;// 排序
	@Column(name="person_smallphoto")
	private String smallphoto;
	
	
	@ManyToOne(cascade = CascadeType.ALL,fetch=FetchType.EAGER)
	@JoinColumn(name = "area_id", referencedColumnName = "area_id",nullable=false)
	private PMEArea area;//一个人员对应一个区域
	
	@OneToMany(mappedBy = "person", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	private Set<PMESMS> sms;
	
	@ManyToMany(cascade = CascadeType.ALL,fetch=FetchType.EAGER)
	@JoinTable(name = "pme_basis_person_duties", joinColumns = @JoinColumn(name = "person_id") , inverseJoinColumns = @JoinColumn(name = "duties_id") )
	private Set<PMEDuties> duties;
	
	@ManyToMany(mappedBy="persons",cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)
	private Set<PMEMetting> mettings;
	
	@ManyToMany(cascade = CascadeType.ALL,fetch=FetchType.EAGER)
	@JoinTable(name = "pme_basis_person_type", joinColumns = @JoinColumn(name = "person_id") , inverseJoinColumns = @JoinColumn(name = "pType_id") )
	private Set<PMEPersonType> pTypes;
	
	public Set<PMEPersonType> getpTypes() {
		return pTypes;
	}

	public void setpTypes(Set<PMEPersonType> pTypes) {
		this.pTypes = pTypes;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getBirthday() {
		return birthday;
	}

	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}

	public Integer getSex() {
		return sex;
	}

	public void setSex(Integer sex) {
		this.sex = sex;
	}

	public String getIdCard() {
		return idCard;
	}

	public void setIdCard(String idCard) {
		this.idCard = idCard;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getPolitics() {
		return politics;
	}

	public void setPolitics(String politics) {
		this.politics = politics;
	}

	public String getNation() {
		return nation;
	}

	public void setNation(String nation) {
		this.nation = nation;
	}

	public String getJoinPartyTime() {
		return joinPartyTime;
	}

	public void setJoinPartyTime(String joinPartyTime) {
		this.joinPartyTime = joinPartyTime;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getEducation() {
		return education;
	}

	public void setEducation(String education) {
		this.education = education;
	}

	public String getJoinworktime() {
		return joinworktime;
	}

	public void setJoinworktime(String joinworktime) {
		this.joinworktime = joinworktime;
	}

	public String getIdentity() {
		return identity;
	}

	public void setIdentity(String identity) {
		this.identity = identity;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		
		this.password = MD5.MD5Encode(password);
	}

	public Date getCreattime() {
		return creattime;
	}

	public void setCreattime(Date creattime) {
		this.creattime = creattime;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Long getSort() {
		return sort;
	}

	public void setSort(Long sort) {
		this.sort = sort;
	}

	public PMEArea getArea() {
		return area;
	}

	public void setArea(PMEArea area) {
		this.area = area;
	}

	public Set<PMESMS> getSms() {
		return sms;
	}

	public void setSms(Set<PMESMS> sms) {
		this.sms = sms;
	}

	public Set<PMEDuties> getDuties() {
		return duties;
	}

	public void setDuties(Set<PMEDuties> duties) {
		this.duties = duties;
	}

	public Set<PMEMetting> getMettings() {
		return mettings;
	}

	public void setMettings(Set<PMEMetting> mettings) {
		this.mettings = mettings;
	}

	public String getSmallphoto() {
		return smallphoto;
	}

	public void setSmallphoto(String smallphoto) {
		this.smallphoto = smallphoto;
	}
}
